<?php

# This initiates an anonymous session and creates the required directories if they don't exist. 
#  Pay attention to the folder names in code, in case you change something elsewhere.
$_SESSION['logged'] = true;
$_SESSION['user'] = "anonymous".substr(sha1(rand()), 0, 6);
$_SESSION['session_id'] = (int)(rand() * 100000);
$_SESSION['uploads'] =  dirname(__FILE__)."/users/".$_SESSION['user']."/uploads/";
$_SESSION['processed'] =  dirname(__FILE__)."/users/".$_SESSION['user']."/processed/";
$_SESSION['homedir'] =  dirname(__FILE__)."/users/".$_SESSION['user']."/";
$_SESSION['completed'] =  $_SESSION['homedir']."completed/";
$_SESSION['filterlist'] = dirname(__FILE__)."/users/".$_SESSION['user']."/filterlist/";
$_SESSION['filterlist_file'] = "filterlist.txt";
$_SESSION['language'] = "default"; 					// Default value..
if(!is_dir($_SESSION['homedir']))
  mkdir($_SESSION['homedir']);
if(!is_dir($_SESSION['uploads']))
  mkdir($_SESSION['uploads']);
if(!is_dir($_SESSION['processed']))
  mkdir($_SESSION['processed']);
if(!is_dir($_SESSION['completed']))
  mkdir($_SESSION['completed']);
if(!is_dir($_SESSION['filterlist'])){
      	mkdir($_SESSION['filterlist']);
      	$filePath = $_SESSION['filterlist'].$_SESSION['filterlist_file'];
	$fileHandle = fopen($filePath, 'w') or die("can't open file");
	fwrite($fileHandle, 'TestStringThatShouldNeverAppearInTheText[CAN BE DELETED]');
	fclose($fileHandle);
}
header("Location: ./index.php?p=file_management");
?>
